<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%  
   if (request.getSession().getAttribute("Login") != null) 
   {
    String message = (String) request.getSession().getAttribute("Login");
    if (!message.equals("true"))
    {
     //如果登录标志不为true则跳转回登录页面
     response.sendRedirect("index.jsp");
    }
    else
    {
    	request.getSession().setAttribute("Login","true");
    }   
   }
   else
   {
    	response.sendRedirect("index.jsp");
   }
  %>
  <%  
   if (request.getSession().getAttribute("AddNews") != null) 
   {
	    String message = (String) request.getSession().getAttribute("AddNews");
	    if ( message.equals("Failed") )
	    {
	    
	     	System.out.println(message+"Failed");
	    }
	    else if (message.equals("Success"))
	    {
	    	System.out.println("Success");
	    }   
   }
  %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>添加新闻</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Language" content="ch-cn">
  <style type="text/css">
<!--
body {
	background-image: url();
	background-color: #2E77ED;
}
-->
</style></head>
  <body>	

  <div align="center">
    <p><img src="<%=request.getContextPath()%>/PIC/top.jpg" alt="" width="820"
			height="115"></p>
    <table width="534" border="0" align="center">
      <tr>
        <td width="217"><div align="center"><a href="AddNewsMain.jsp">添加新闻</a> <br>
        </div></td>
        <td width="307"><div align="center"><a href="ShowNews?method=view">查看新闻 </a> </div></td>
      </tr>
    </table>
         <script language="javaScript">
   	function detailCheck()
     {  
      var sdetail = document.addNewsForm.detail.value;
      var stitle = document.addNewsForm.title.value;
      var sdigest = document.addNewsForm.digest.value;
      if( sdetail==""||stitle==""||sdigest=="")
      {
       	alert("标题、摘要、内容中不能为空！");
      	 return false;
      }
      return true;
     }
    </script>
    <form action="addNewsServlet" method="post" onsubmit="detailCheck()" enctype="multipart/form-data" name="addNewsForm" id="addNewsForm" >
      <table width="805" border="1" align="center" bordercolor="#33F2E9">
        <tr>
          <th width="212" bgcolor="#33F2E9" scope="row">新闻类型：</th>
          <td width="577" bgcolor="#33F2E9"><label>
            <select name="Category" size="1" id="Category">
              <option value="1" selected>焦点</option>
			  <option value="2">通知</option>
			  <option value="3">学校</option>
			  <option value="4">国内</option>
			  <option value="5">国际</option>
			  <option value="6">科技</option>
			  <option value="7">体育</option>
			  <option value="8">文艺</option>
			  <option value="9">社团</option>
			  <option value="10">就业</option>
		    </select>
          </label></td>
        </tr>
        <tr>
          <th bgcolor="#33F2E9" scope="row">新闻标题：</th>
          <td bgcolor="#33F2E9"><input name="title" type="text" id="title" size="80" maxlength="300"></td>
        </tr>
        <tr>
          <th bgcolor="#33F2E9" scope="row">新闻摘要:</th>
          <td bgcolor="#33F2E9"><textarea name="digest" cols="80" rows="6" id="digest"></textarea></td>
        </tr>
        <tr>
          <th bgcolor="#33F2E9" scope="row">新闻内容:</th>
          <td bgcolor="#FFFFFF"><textarea name="detail" cols="80" rows="25" id="detail"></textarea></td>
        </tr>
        <tr>
          <th bgcolor="#33F2E9" scope="row">新闻来源：</th>
          <td bgcolor="#33F2E9"><select name="source">
            <option value="校党委">校党委</option>
            <option value="校团委">校团委</option>
            <option value="校宣传部">校宣传部</option>
            <option value="校学生会">校学生会</option>
            <option value="理学院团总支" selected>理学院团总支</option>
          </select></td>
        </tr>
        <tr>
          <th bgcolor="#33F2E9" scope="row">&nbsp; 新闻图片:&nbsp;&nbsp;&nbsp; </th>
          <td bgcolor="#33F2E9"><input name="imgsrc" type="file" id="imgsrc" size="60"></td>
        </tr>
        <tr>
          <th colspan="2" bgcolor="#33F2E9" scope="row"><p>&nbsp;
            </p>
            <p>
            <input type="submit" value="提交" name="submit" >
            &nbsp;
		    <input type="reset" value="重置" name="reset">
          </p></th>
        </tr>
      </table>
    </form>
     
    <p>&nbsp;</p>
  </div>
  <div align="center">
  <!-- ///C|/Users/Administrator/Desktop/xxgk2_r1_c1.jpg -->
  </div>


</body>
</html>
